import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import com.adc.quicktools.ObjectUtil;
import com.adc.quicktools.StringUtil;

/**********************************************************************************
 * Copyright (c) 2012 - 2012,  quick_tools, All right reserved
 * Title:   Test2.java 
 * @author shen  shenqiao2012@163.com 
 *  2012-7-2 上午12:40:14 
 *********************************************************************************/

public class TestObjectUtil {

	public static void testReflect() {
		Field[] fields = Student.class.getDeclaredFields();
		Method[] methods=Student.class.getDeclaredMethods();
//		for (Field field : fields) {
//			System.out.println(field.getName()+"  "+field.getModifiers());
//		}
		for (Method method : methods) {
			System.out.println(method.getName()+"  "+method.getReturnType().getSimpleName());
		}
	}
	
	public static void testObjectUtil(int t) {
		Student student1=new Student();
		Student student2=new Student();
		Teacher teacher=new Teacher();
		teacher.setKind("myName");
		teacher.setDept("man");
		Field[] fields = student1.getClass().getDeclaredFields();
		for (Field field : fields) {
			if (field.getName().equals("name")) {
				ObjectUtil.setter(student1, field.getName(), "myName", String.class);
				ObjectUtil.setter(student2, field.getName(), "myName", String.class);
			}
			else if (field.getName().equals("sex")) {
				ObjectUtil.setter(student1, field.getName(), "man", String.class);
				ObjectUtil.setter(student2, field.getName(), "man", String.class);
			}
//			ObjectUtil.getter(student, field.getName());
		}
		if (t==1) {
			System.err.println("func1:" + ObjectUtil.objectEquals(student1, student2));
		}else if(t==2){
			System.err.println("func2:"+ObjectUtil.objectEquals2(student1, student2));
		}
		System.out.println("-----------------------------");		
		
	}
	
	public static void testObjectEquals() {
		testObjectUtil(1);
		try {
			Thread.sleep(3000L);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		testObjectUtil(2);
	}
	
	public static void testGetNameByString() {
		System.out.println(StringUtil.getNameByString("/D:/home/cipas/DCM/product/DSTR/FF/PMON/2009"));
	}
	
	/**
	 * Description: 这里用一句话描述这个方法的作用 
	 * author:  shen
	 * @param args 
	 * @return void
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
//		testReflect();
//		testObjectEquals();
		testGetNameByString();
	}

}
